package com.zhsq.zlc.rest;


import com.zhsq.zlc.service.user.UserService;
import com.zhsq.zlc.entity.UserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/nlp")
public class RestTestController {

    @Autowired
    private UserService userService;

    @RequestMapping(value = { "/getAllStrs" }, method = RequestMethod.GET)
    public ResultModel getAllUsers() {
        try {
            List<String> list=new ArrayList<String>();
            list.add("111");
            list.add("222");
            list.add("333");
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("res", list);
            return ResultTools.result(0, "", map);
        } catch (Exception e) {
            return ResultTools.result(404, e.getMessage(), null);
        }
    }

    @RequestMapping(value = { "/getUserById" }, method = RequestMethod.GET)
    public ResultModel selectUserById(Integer id) {
        try {
            if (null == id) {
                return ResultTools.result(1001, "", null);
            }
            UserEntity temp=new UserEntity();
            temp.setId(id);
            UserEntity user = userService.getUserById(temp);
            if (null == user) {
                return ResultTools.result(1002, "", null);
            }
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("res", user);
            return ResultTools.result(0, "", map);
        } catch (Exception e) {
            return ResultTools.result(404, e.getMessage(), null);
        }
    }
    @RequestMapping(value = { "/getUsersByCondition" }, method = RequestMethod.POST)
    public ResultModel getUsersByCondition(Map<String,Object> params) {
        try {
            if (null == params.get("id")) {
                return ResultTools.result(1001, "", null);
            }
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("res", null);
            return ResultTools.result(0, "", map);
        } catch (Exception e) {
            return ResultTools.result(404, e.getMessage(), null);
        }
    }

}
